<?php
/**
 * Created by Pako
 * Date: 2019/5/15
 * Time: 22:06
 */

namespace App\Http\Controllers\Admin\Ad;


use App\Http\Request\Ad\PositionStore;
use App\Repositories\Ad\PositionRepository;
use Illuminate\Http\Request;

class PositionController
{
    private $position ;

    public function __construct(PositionRepository $position)
    {
        $this->position = $position;
    }


    public function index()
    {
        return $this->position->index();
    }

    /**
     * 描术
     *
     * @author Pako
     * @createTime 2019/5/15 22:09
     * @param PositionStore $position
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(PositionStore $position,Request $request)
    {
        $params = $position->validated($request);
        return $this->position->store($params);
    }

    /**
     * 描术
     *
     * @author Pako
     * @createTime 2019/5/15 22:10
     * @param PositionStore $position
     * @param $
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function save(PositionStore $position,Request $request)
    {
        $params = $position->validated($request);
        return $this->position->save($params);
    }

    public function del(Request $request)
    {
        $position_id = $request->input('position_id',0);
        return $this->position->del($position_id);
    }
}